package Beans;

import BO.Service;
import UI.*;
import java.io.Serializable;
import java.util.List;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

public class InterestBean implements Serializable{

    private String newInterest;
    private List<InterestUI> interests;
    
    public InterestBean() {
    }

    public String getNewInterest() {
        return newInterest;
    }

    public void setNewInterest(String newInterest) {
        this.newInterest = newInterest;
    }

    public List<InterestUI> getInterests() {
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        UserUI user = (UserUI)session.getAttribute("User");
        interests = Service.getUserInterests(user.getId());
        return interests; 
    }

    public void setInterests(List<InterestUI> interests) {
        this.interests = interests;
    }
    
    public void addInterest(){
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        UserUI user = (UserUI)session.getAttribute("User");
        Service.addInterest(user.getId(), newInterest);
    }
    
    
}
